<?php

BLoader::import('../plugin/sphinx/sphinx');

class BPlugin_sphinx extends SphinxClient
{
   private $_flag = array(1=> 'default', 2=>'list', 3=>'sort', 4=>'relation');

   function __construct($flag = 1)
   {
        parent::SphinxClient();
   }

   function getEngine ($flag = 1)
   {
        $config = B::i()->config->sphinx;

        $url = parse_url($config[$this->_flag[$flag]]);
        $this->SetServer($url['host'], $url['port']);
        $this->SetConnectTimeout(1);
        $this->SetMatchMode(SPH_MATCH_EXTENDED);
        $this->SetArrayResult(true);
        return $this;
   }

   function SetMatchMode ($mode = SPH_MATCH_EXTENDED)
   {
        return parent::SetMatchMode($mode);
   }

}
